/**
 *
 */
package com.malljelly.study.social.qq.properties;

import com.malljelly.study.social.qq.connet.QQConnectionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.social.SocialAutoConfigurerAdapter;
import org.springframework.context.annotation.Configuration;
import org.springframework.social.connect.ConnectionFactory;


/**
 * @author ConnectionFactory
 *
 */
@Configuration
@ConditionalOnProperty(prefix = "malljelly.security.social.qq", name = "app-id")   //配置文件中有值以后下面才生效,不然不会生效
public class QQAutoConfig extends SocialAutoConfigurerAdapter {

	@Autowired
	private QQProperties qqProperties;

	/*
	 * (non-Javadoc)
	 *
	 * @see
	 * org.springframework.boot.autoconfigure.social.SocialAutoConfigurerAdapter
	 * #createConnectionFactory()
	 */
	@Override
	protected ConnectionFactory<?> createConnectionFactory() {
		return new QQConnectionFactory(qqProperties.getProviderId(), qqProperties.getAppId(), qqProperties.getAppSecret());
	}

}
